package com.eco.fanliapp.admin.controller.web;


import com.eco.fanliapp.admin.annotation.SysLogAnnotation;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppMessage;
import com.eco.fanliapp.service.IAppMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/web/message")
public class WebMessageController {
        @Autowired
        private IAppMessageService appMessageService ;

    /**
     *  新写入数据库记录,app_message
     *
     * @param message
     */
    @SysLogAnnotation(value = "app_message添加数据",userType = 2)
    @PostMapping("/insertAppMessage")
    public ServerResponse<AppMessage> insertAppMessage(@RequestBody AppMessage message){
          return appMessageService.insert(message);
      }

    /**
     * 根据消息代号更改消息内容
     * @param message
     * @return
     */
    @PostMapping("/updateByMessageCode")
    public ServerResponse<AppMessage> updateByMessageCode(@RequestBody AppMessage message){
        return appMessageService.updateByMessageCode(message);
    }

    /**
     *  根据指定消息代号获取一条数据库记录,app_message
     *
     * @param messageCode
     */
    @RequestMapping("/selectByMessageCode")
    public ServerResponse<AppMessage> selectByMessageCode(String messageCode){
        return appMessageService.selectByMessageCode(messageCode);
    }

}
